<%--
  Created by IntelliJ IDEA.
  User: chunyang
  Date: 2016/6/16
  Time: 21:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,
                                     initial-scale=1.0,
                                     maximum-scale=1.0,
                                     user-scalable=no">
    <title>领取保险</title>
    <link href="${ctx}/static/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/static/pingan/css/event.css" rel="stylesheet">
    <link href="${ctx}/static/pingan/css/style.css" rel="stylesheet">
    <script type="text/javascript" src="${ctx}/static/jquery/json2.js"></script>
    <style>
        body{background: #ffffff;}
    </style>
</head>
<body>
<div class="container" style=" margin:0px auto; overflow-x:hidden;">
    <div class="row">
        <div class="col-xs-12 col-md-12 col-sm-12 col-lg-12" style="padding:0; text-align:center; font-size:16px;">
            <div class="box_hui">
                <div style="text-align:center; background:#FFFFFF; padding:0.5em 0; margin-bottom:0.3em;">确认身份信息</div>
            </div>
            <div class="box_hui">
                <div style="text-align:left; padding-left:1em;">
                    <p style="margin: 0 0 10px 5px;">为确保保险的成功领取，请确认您的个人信息。</p>
                    <br/>

                    <form action="" method="post" id="form">
                        <input type="hidden" id="volunteerCode" value="${volunteerCode}" name="volunteerCode">
                        <input type="hidden" id="platform" value="${platform}" name="platform">
                        <input type="hidden" id="memberCode" value="${memberCode}" name="memberCode">
                        <ul style="background:#FFFFFF;">
                            <li>
                                <div class="tit">姓名</div>
                                <input placeholder="真实姓名" value="${realName}" id="name" name="name">
                            </li>
                            <li>
                                <div class="tit">身份证</div>
                                <input placeholder="真实身份证号" value="${cardNO}" id="idCard" name="idCard">
                            </li>
                            <li>
                                <div class="tit">手机</div>
                                <input placeholder="请输入手机号码" value="${mobile}" id="mobile" name="mobile">
                            </li>
                            <c:if test="${type eq 'N'}">
                                <li>
                                    <div class="tit">监护人</div>
                                    <input placeholder="监护人姓名" value="" id="guardianName" name="guardianName">
                                </li>
                                <li>
                                    <div class="tit">监护人证件</div>
                                    <input placeholder="监护人身份证号" value="" id="guardianIDCard" name="guardianIDCard">
                                </li>
                                <li>
                                    <div class="tit">监护人手机</div>
                                    <input placeholder="监护人手机号码" value="" id="guardianMobile" name="guardianMobile">
                                </li>
                            </c:if>
                        </ul>
                        <input type="button" value="确定" id="submit" class="app-btn2"/>
                    </form>
                    <div style="font-size:0.8em; text-align:left; padding-left:1em;" id="wait2"></div>
                </div>
            </div>
        </div>
    </div>
</div>
    <style>
        ul {
            list-style: none;
            padding: 0;
            text-align: left;
        }

        li {
            padding: 0.5em 1em;
            border-bottom: 1px solid #EFEFEF;
            width: 100%;
        }
        input {
            border: 0;
            background: #FFFFFF;
            width: 11em;
        }
    </style>

    <script type="text/javascript" src="${ctx}/static/jquery/jquery-1.9.1.min.js"></script>
    <script>
        (function($){
            $.fn.serializeJson=function(){
                var serializeObj={};
                var array=this.serializeArray();
                var str=this.serialize();
                $(array).each(function(){
                    if(serializeObj[this.name]){
                        if($.isArray(serializeObj[this.name])){
                            serializeObj[this.name].push(this.value);
                        }else{
                            serializeObj[this.name]=[serializeObj[this.name],this.value];
                        }
                    }else{
                        serializeObj[this.name]=this.value;
                    }
                });
                return serializeObj;
            };
        })(jQuery);

        //再將 jQuery.toJSON(obj) 置換成 JSON.stringify(obj) 即可

        $(document).ready(
                function() {
                    $("#submit").click(function() {
                        var value = $("#form").serializeJson(); //自动将form表单封装成json
                        value = JSON.stringify(value);
                        jQuery.ajax( {
                            type : 'POST',
                            contentType : 'application/json',
                            url : '${ctx}/pa/create',
                            data : value,
                            dataType : 'json',
                            success : function(data) {
                                if(data.code == 0)
                                    window.location.href = "${ctx}/pa/insurance/${volunteerCode}";
                                else
                                    alert(data.message);

                            },
                            error : function(data) {
                                alert(data.message);
                            }
                        });

                    });
                });
    </script>

</body>
</html>

